gtk: Add private _gtk_toplevel_pick() method
authorCarlos Garnacho <carlosg@gnome.org>
Fri, 31 Mar 2017 14:49:22 +0000 (16:49 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 25 May 2017 14:25:58 +0000 (16:25 +0200)
This function returns both the widget at the given toplevel coordinates,
and the translated x/y in widget relative coordinates.

gtk/gtkmain.c
gtk/gtkprivate.h

index b145f0063d1135e28b19df145d3f698c7d68301e..70b143938cae7a23f62a02c7fb3264466ca0f5ed 100644 (file)
@@ -2304,3 +2304,26 @@ _gtk_propagate_captured_event (GtkWidget *widget,
 {
   return propagate_event (widget, event, TRUE, topmost);
 }
+
+GtkWidget *
+_gtk_toplevel_pick (GtkWindow *toplevel,
+                    gdouble    x,
+                    gdouble    y,
+                    gdouble   *x_out,
+                    gdouble   *y_out)
+{
+  GtkWidget *target = NULL, *widget = GTK_WIDGET (toplevel);
+
+  while (widget)
+    {
+      target = widget;
+      widget = GTK_WIDGET_GET_CLASS (target)->pick (widget, x, y, &x, &y);
+    }
+
+  if (x_out)
+    *x_out = x;
+  if (y_out)
+    *y_out = y;
+
+  return target;
+}
index de26e9ff8934f11d2f14b380f82f2b27d938ca78..21de4862e294c83148839c03fce88cadf069e49b 100644 (file)
@@ -91,6 +91,11 @@ gboolean        _gtk_propagate_captured_event  (GtkWidget       *widget,
                                                 GdkEvent        *event,
                                                 GtkWidget       *topmost);
 
+GtkWidget *     _gtk_toplevel_pick (GtkWindow *toplevel,
+                                    gdouble    x,
+                                    gdouble    y,
+                                    gdouble   *x_out,
+                                    gdouble   *y_out);
 
 gdouble _gtk_get_slowdown (void);
 void    _gtk_set_slowdown (gdouble slowdown_factor);